﻿Imports DataObject
Imports BusinessObject
Imports Microsoft.ApplicationBlocks.Data

Public Class frmTinhTrangHopDongList

    Private oTinhTrangHopDong As New BusTinhTrangHopDong
    Private oPrvTinhTrangHopDong As New TinhTrangHopDong
    Private oConn As New hDBase

    Private Sub frmTinhTrangHopDongList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        InitData()
        LoadGridView()
        RefreshToolbar()
    End Sub

    Protected Overrides Sub LoadDataGrid()
        Try
            tableDictionary = oTinhTrangHopDong.GetAllTinhTrangHopDong(sConn)
            ListBindingSource.DataSource = tableDictionary
            grdList.DataSource = ListBindingSource
        Catch ex As Exception
            MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Private Sub LoadGridView()
        grdList.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect
        With grdList.DisplayLayout.Bands(0)
            .Columns("SoTinhTrangHopDong").Hidden = True
            .Columns("MaTinhTrangHopDong").Header.Caption = "Mã tình trạng"
            .Columns("TenTinhTrangHopDong").Header.Caption = "Tên tình trạng"
            .Columns("DienGiai").Header.Caption = "Diễn giải"

            .Columns("MaTinhTrangHopDong").Width = 50
            .Columns("TenTinhTrangHopDong").Width = 100
        End With
    End Sub

    Protected Overrides Sub InitAddNewRow(ByVal oRow As System.Data.DataRow)
        With oRow
            .Item("MaTinhTrangHopDong") = ""
            .Item("TenTinhTrangHopDong") = ""
            .Item("DienGiai") = ""
        End With
    End Sub

    Protected Overrides Function DeleteDictionary() As Boolean
        oPrvTinhTrangHopDong.SoTinhTrangHopDong = iValue
        oTinhTrangHopDong.DeleteTinhTrangHopDong(sConn, oPrvTinhTrangHopDong)
    End Function

    Private Sub grdList_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdList.MouseClick
        Try
            iValue = grdList.ActiveRow.Cells(TablePrimaryKey).Value
        Catch ex As Exception
        End Try
    End Sub

End Class
